package com.exchange.Public;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.location.Location;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.os.Bundle;
import android.os.Environment;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.zip.Deflater;
import javax.microedition.khronos.opengles.GL10;

public class h
{
  static String a;
  public static int b;
  private static Set<String> c = null;

  static
  {
    a = "utf-8";
  }

  public static int a(int paramInt, Context paramContext)
  {
    return (int)(0.5F + paramContext.getResources().getDisplayMetrics().density * paramInt);
  }

  public static int a(Context paramContext, float paramFloat)
  {
    return Math.round(paramFloat * paramContext.getResources().getDisplayMetrics().heightPixels);
  }

  public static int a(Date paramDate1, Date paramDate2)
  {
    Date localDate1;
    Date localDate2;
    if (paramDate1.after(paramDate2))
    {
      localDate1 = paramDate1;
      localDate2 = paramDate2;
    }
    while (true)
    {
      long l = localDate2.getTime();
      return (int)((localDate1.getTime() - l) / 1000L);
      localDate1 = paramDate2;
      localDate2 = paramDate1;
    }
  }

  // ERROR //
  public static String a()
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_0
    //   2: new 72	java/io/FileReader
    //   5: dup
    //   6: ldc 74
    //   8: invokespecial 77	java/io/FileReader:<init>	(Ljava/lang/String;)V
    //   11: astore_1
    //   12: aload_1
    //   13: ifnull +32 -> 45
    //   16: new 79	java/io/BufferedReader
    //   19: dup
    //   20: aload_1
    //   21: sipush 1024
    //   24: invokespecial 82	java/io/BufferedReader:<init>	(Ljava/io/Reader;I)V
    //   27: astore_2
    //   28: aload_2
    //   29: invokevirtual 85	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   32: astore 8
    //   34: aload 8
    //   36: astore_0
    //   37: aload_2
    //   38: invokevirtual 88	java/io/BufferedReader:close	()V
    //   41: aload_1
    //   42: invokevirtual 89	java/io/FileReader:close	()V
    //   45: aload_0
    //   46: ifnull +16 -> 62
    //   49: aload_0
    //   50: iconst_1
    //   51: aload_0
    //   52: bipush 58
    //   54: invokevirtual 95	java/lang/String:indexOf	(I)I
    //   57: iadd
    //   58: invokevirtual 99	java/lang/String:substring	(I)Ljava/lang/String;
    //   61: astore_0
    //   62: aload_0
    //   63: invokevirtual 102	java/lang/String:trim	()Ljava/lang/String;
    //   66: areturn
    //   67: astore 6
    //   69: aconst_null
    //   70: astore 4
    //   72: aload 6
    //   74: astore 7
    //   76: getstatic 107	com/exchange/Public/ExchangeConstants:LOG_TAG	Ljava/lang/String;
    //   79: ldc 109
    //   81: aload 7
    //   83: invokestatic 114	com/exchange/Public/n:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    //   86: aload 4
    //   88: astore_0
    //   89: goto -44 -> 45
    //   92: astore_3
    //   93: aconst_null
    //   94: astore 4
    //   96: aload_3
    //   97: astore 5
    //   99: getstatic 107	com/exchange/Public/ExchangeConstants:LOG_TAG	Ljava/lang/String;
    //   102: ldc 116
    //   104: aload 5
    //   106: invokestatic 114	com/exchange/Public/n:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    //   109: aload 4
    //   111: astore_0
    //   112: goto -67 -> 45
    //   115: astore 10
    //   117: aload_0
    //   118: astore 4
    //   120: aload 10
    //   122: astore 5
    //   124: goto -25 -> 99
    //   127: astore 5
    //   129: goto -30 -> 99
    //   132: astore 9
    //   134: aload_0
    //   135: astore 4
    //   137: aload 9
    //   139: astore 7
    //   141: goto -65 -> 76
    //
    // Exception table:
    //   from	to	target	type
    //   16	34	67	java/io/IOException
    //   2	12	92	java/io/FileNotFoundException
    //   16	34	92	java/io/FileNotFoundException
    //   37	45	115	java/io/FileNotFoundException
    //   76	86	127	java/io/FileNotFoundException
    //   37	45	132	java/io/IOException
  }

  public static String a(String paramString)
  {
    return ExchangeConstants.banben + paramString;
  }

  public static String a(Date paramDate)
  {
    return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(paramDate);
  }

  public static void a(Context paramContext, Date paramDate)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("exchange_last_request_time", 0).edit();
    localEditor.putString("last_request_time", a(paramDate));
    localEditor.commit();
  }

  public static boolean a(Context paramContext)
  {
    return paramContext.getResources().getConfiguration().locale.toString().equals("zh_CN");
  }

  public static boolean a(Context paramContext, String paramString)
  {
    int i;
    if (paramContext.getPackageManager().checkPermission(paramString, paramContext.getPackageName()) != 0)
      i = 0;
    while (true)
    {
      return i;
      i = 1;
    }
  }

  public static boolean a(String paramString, Context paramContext)
  {
    int i;
    PackageManager localPackageManager = paramContext.getPackageManager();
    try
    {
      localPackageManager.getPackageInfo(paramString, 1);
      i = 1;
      return i;
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      i = 0;
    }
  }

  public static String[] a(GL10 paramGL10)
  {
    String[] arrayOfString;
    try
    {
      arrayOfString = new String[2];
      String str1 = paramGL10.glGetString(7936);
      String str2 = paramGL10.glGetString(7937);
      arrayOfString[0] = str1;
      arrayOfString[1] = str2;
      return arrayOfString;
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "Could not read gpu infor:", localException);
      arrayOfString = new String[0];
    }
  }

  public static void b(Context paramContext)
  {
    int i = 0;
    HashSet localHashSet = new HashSet();
    List localList = paramContext.getPackageManager().getInstalledPackages(0);
    while (true)
    {
      if (i >= localList.size())
      {
        c = localHashSet;
        return;
      }
      localHashSet.add(((PackageInfo)localList.get(i)).packageName);
      ++i;
    }
  }

  public static boolean b()
  {
    int i;
    if (Environment.getExternalStorageState().equals("mounted"))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public static byte[] b(String paramString)
    throws IOException
  {
    b = 0;
    Deflater localDeflater = new Deflater();
    localDeflater.setInput(paramString.getBytes(a));
    localDeflater.finish();
    byte[] arrayOfByte = new byte[8192];
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    while (true)
    {
      if (localDeflater.finished())
      {
        localDeflater.end();
        return localByteArrayOutputStream.toByteArray();
      }
      int i = localDeflater.deflate(arrayOfByte);
      b = i + b;
      localByteArrayOutputStream.write(arrayOfByte, 0, i);
    }
  }

  public static Date c(String paramString)
  {
    Date localDate1;
    Date localDate2;
    try
    {
      localDate2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(paramString);
      localDate1 = localDate2;
      return localDate1;
    }
    catch (Exception localException)
    {
      localDate1 = null;
    }
  }

  public static Set<String> c(Context paramContext)
  {
    if (c == null)
      b(paramContext);
    return c;
  }

  public static boolean d(Context paramContext)
  {
    int i;
    if (paramContext.getResources().getConfiguration().orientation == 1)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  // ERROR //
  public static org.json.JSONObject e(Context paramContext)
  {
    // Byte code:
    //   0: new 308	org/json/JSONObject
    //   3: dup
    //   4: invokespecial 309	org/json/JSONObject:<init>	()V
    //   7: astore_1
    //   8: aload_1
    //   9: ldc_w 311
    //   12: aload_0
    //   13: ldc_w 313
    //   16: invokevirtual 317	android/content/Context:getSystemService	(Ljava/lang/String;)Ljava/lang/Object;
    //   19: checkcast 319	android/telephony/TelephonyManager
    //   22: invokevirtual 322	android/telephony/TelephonyManager:getDeviceId	()Ljava/lang/String;
    //   25: invokevirtual 326	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   28: pop
    //   29: aload_1
    //   30: ldc_w 328
    //   33: aload_0
    //   34: invokevirtual 195	android/content/Context:getPackageManager	()Landroid/content/pm/PackageManager;
    //   37: aload_0
    //   38: invokevirtual 198	android/content/Context:getPackageName	()Ljava/lang/String;
    //   41: iconst_0
    //   42: invokevirtual 211	android/content/pm/PackageManager:getPackageInfo	(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;
    //   45: getfield 331	android/content/pm/PackageInfo:versionName	Ljava/lang/String;
    //   48: invokevirtual 326	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   51: pop
    //   52: aload_1
    //   53: ldc_w 333
    //   56: getstatic 338	android/os/Build$VERSION:RELEASE	Ljava/lang/String;
    //   59: invokevirtual 326	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   62: pop
    //   63: new 177	android/content/res/Configuration
    //   66: dup
    //   67: invokespecial 339	android/content/res/Configuration:<init>	()V
    //   70: astore 7
    //   72: aload_0
    //   73: invokevirtual 343	android/content/Context:getContentResolver	()Landroid/content/ContentResolver;
    //   76: aload 7
    //   78: invokestatic 348	android/provider/Settings$System:getConfiguration	(Landroid/content/ContentResolver;Landroid/content/res/Configuration;)V
    //   81: aload 7
    //   83: getfield 181	android/content/res/Configuration:locale	Ljava/util/Locale;
    //   86: ifnull +61 -> 147
    //   89: aload_1
    //   90: ldc_w 350
    //   93: aload 7
    //   95: getfield 181	android/content/res/Configuration:locale	Ljava/util/Locale;
    //   98: invokevirtual 353	java/util/Locale:getCountry	()Ljava/lang/String;
    //   101: invokevirtual 326	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   104: pop
    //   105: aload_1
    //   106: ldc_w 355
    //   109: aload 7
    //   111: getfield 181	android/content/res/Configuration:locale	Ljava/util/Locale;
    //   114: invokevirtual 184	java/util/Locale:toString	()Ljava/lang/String;
    //   117: invokevirtual 326	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   120: pop
    //   121: aload_1
    //   122: ldc_w 357
    //   125: aload 7
    //   127: getfield 181	android/content/res/Configuration:locale	Ljava/util/Locale;
    //   130: invokestatic 363	java/util/Calendar:getInstance	(Ljava/util/Locale;)Ljava/util/Calendar;
    //   133: invokevirtual 367	java/util/Calendar:getTimeZone	()Ljava/util/TimeZone;
    //   136: invokevirtual 372	java/util/TimeZone:getRawOffset	()I
    //   139: ldc_w 373
    //   142: idiv
    //   143: invokevirtual 376	org/json/JSONObject:put	(Ljava/lang/String;I)Lorg/json/JSONObject;
    //   146: pop
    //   147: aload_1
    //   148: ldc_w 378
    //   151: dconst_0
    //   152: invokevirtual 381	org/json/JSONObject:put	(Ljava/lang/String;D)Lorg/json/JSONObject;
    //   155: pop
    //   156: aload_1
    //   157: ldc_w 383
    //   160: dconst_0
    //   161: invokevirtual 381	org/json/JSONObject:put	(Ljava/lang/String;D)Lorg/json/JSONObject;
    //   164: pop
    //   165: new 137	java/text/SimpleDateFormat
    //   168: dup
    //   169: ldc 139
    //   171: invokespecial 140	java/text/SimpleDateFormat:<init>	(Ljava/lang/String;)V
    //   174: new 55	java/util/Date
    //   177: dup
    //   178: invokespecial 384	java/util/Date:<init>	()V
    //   181: invokevirtual 387	java/text/DateFormat:format	(Ljava/util/Date;)Ljava/lang/String;
    //   184: astore 10
    //   186: aload 10
    //   188: ldc_w 389
    //   191: invokevirtual 393	java/lang/String:split	(Ljava/lang/String;)[Ljava/lang/String;
    //   194: iconst_0
    //   195: aaload
    //   196: astore 11
    //   198: aload 10
    //   200: ldc_w 389
    //   203: invokevirtual 393	java/lang/String:split	(Ljava/lang/String;)[Ljava/lang/String;
    //   206: iconst_1
    //   207: aaload
    //   208: astore 12
    //   210: aload_1
    //   211: ldc_w 395
    //   214: aload 11
    //   216: invokevirtual 326	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   219: pop
    //   220: aload_1
    //   221: ldc_w 397
    //   224: aload 12
    //   226: invokevirtual 326	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   229: pop
    //   230: goto +30 -> 260
    //   233: astore 4
    //   235: aload_1
    //   236: ldc_w 328
    //   239: ldc_w 399
    //   242: invokevirtual 326	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   245: pop
    //   246: goto -194 -> 52
    //   249: astore_2
    //   250: ldc_w 401
    //   253: aload_2
    //   254: invokevirtual 404	java/lang/Exception:getMessage	()Ljava/lang/String;
    //   257: invokestatic 407	com/exchange/Public/n:b	(Ljava/lang/String;Ljava/lang/String;)V
    //   260: aload_1
    //   261: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   29	52	233	android/content/pm/PackageManager$NameNotFoundException
    //   8	29	249	java/lang/Exception
    //   29	52	249	java/lang/Exception
    //   52	246	249	java/lang/Exception
  }

  public static String f(Context paramContext)
  {
    Object localObject = null;
    try
    {
      ApplicationInfo localApplicationInfo = paramContext.getPackageManager().getApplicationInfo(paramContext.getPackageName(), 128);
      if (localApplicationInfo != null)
      {
        String str = localApplicationInfo.metaData.getString("UMENG_APPKEY");
        if (str != null)
          localObject = str;
        else
          n.a(ExchangeConstants.LOG_TAG, "Could not read EXCHANGE_APPKEY meta-data from AndroidManifest.xml.");
      }
    }
    catch (Exception localException)
    {
      n.a(ExchangeConstants.LOG_TAG, "Could not read EXCHANGE_APPKEY meta-data from AndroidManifest.xml.", localException);
    }
    return localObject;
  }

  public static String g(Context paramContext)
  {
    String str1;
    String str2;
    try
    {
      str2 = String.valueOf(paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 0).versionCode);
      str1 = str2;
      return str1;
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      str1 = "unknown";
    }
  }

  public static Date h(Context paramContext)
  {
    return c(paramContext.getSharedPreferences("exchange_last_request_time", 0).getString("last_request_time", "2011-01-01 00:00:00"));
  }

  public static String i(Context paramContext)
  {
    Object localObject;
    TelephonyManager localTelephonyManager;
    try
    {
      localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
      if (localTelephonyManager == null)
      {
        n.e(ExchangeConstants.LOG_TAG, "No IMEI.");
        localObject = "Unknown";
        return localObject;
      }
      String str = localTelephonyManager.getDeviceId();
      localObject = str;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      localObject = "Unknown";
    }
  }

  public static String j(Context paramContext)
  {
    Object localObject;
    TelephonyManager localTelephonyManager;
    try
    {
      localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
      if (localTelephonyManager == null)
      {
        localObject = "Unknown";
        return localObject;
      }
      String str = localTelephonyManager.getNetworkOperatorName();
      localObject = str;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      localObject = "Unknown";
    }
  }

  public static String k(Context paramContext)
  {
    DisplayMetrics localDisplayMetrics;
    String str1;
    try
    {
      localDisplayMetrics = new DisplayMetrics();
      ((WindowManager)paramContext.getSystemService("window")).getDefaultDisplay().getMetrics(localDisplayMetrics);
      int i = localDisplayMetrics.widthPixels;
      String str2 = String.valueOf(localDisplayMetrics.heightPixels) + "*" + String.valueOf(i);
      str1 = str2;
      return str1;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      str1 = "Unknown";
    }
  }

  public static String[] l(Context paramContext)
  {
    String[] arrayOfString = new String[2];
    arrayOfString[0] = "Unknown";
    arrayOfString[1] = "Unknown";
    if (paramContext.getPackageManager().checkPermission("android.permission.ACCESS_NETWORK_STATE", paramContext.getPackageName()) != 0)
      arrayOfString[0] = "Unknown";
    while (true)
    {
      NetworkInfo localNetworkInfo;
      do
      {
        ConnectivityManager localConnectivityManager;
        while (true)
        {
          while (true)
          {
            return arrayOfString;
            localConnectivityManager = (ConnectivityManager)paramContext.getSystemService("connectivity");
            if (localConnectivityManager != null)
              break;
            arrayOfString[0] = "Unknown";
          }
          if (localConnectivityManager.getNetworkInfo(1).getState() != NetworkInfo.State.CONNECTED)
            break;
          arrayOfString[0] = "Wi-Fi";
        }
        localNetworkInfo = localConnectivityManager.getNetworkInfo(0);
      }
      while (localNetworkInfo.getState() != NetworkInfo.State.CONNECTED);
      arrayOfString[0] = "2G/3G";
      arrayOfString[1] = localNetworkInfo.getSubtypeName();
    }
  }

  public static double[] m(Context paramContext)
  {
    double[] arrayOfDouble = new double[2];
    arrayOfDouble[0] = 0D;
    arrayOfDouble[1] = 0D;
    Location localLocation = new g(paramContext).a();
    if (localLocation != null)
    {
      arrayOfDouble[0] = localLocation.getLatitude();
      arrayOfDouble[1] = localLocation.getLongitude();
    }
    return arrayOfDouble;
  }

  public static boolean n(Context paramContext)
  {
    boolean bool1;
    NetworkInfo localNetworkInfo;
    try
    {
      localNetworkInfo = ((ConnectivityManager)paramContext.getSystemService("connectivity")).getActiveNetworkInfo();
      if (localNetworkInfo != null)
      {
        boolean bool2 = localNetworkInfo.isConnectedOrConnecting();
        bool1 = bool2;
        return bool1;
      }
      bool1 = false;
    }
    catch (Exception localException)
    {
      bool1 = true;
    }
  }
}